//
//  FormulateCollectionViewCell.m
//  littleLight's Project-A
//
//  Created by dllo on 16/5/21.
//  Copyright © 2016年 light. All rights reserved.
//

#import "FormulateCollectionViewCell.h"
#import <UIImageView+WebCache.h>
@implementation FormulateCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatView];
    }
    return self;
}


- (void)creatView
{
    self.contentView.layer.masksToBounds = YES;
    self.contentView.layer.cornerRadius = 5;
    
    self.cover_img = [[UIImageView alloc] initWithFrame:CGRectMake(0,self.contentView.frame.size.height / 7, self.contentView.frame.size.width, self.contentView.frame.size.height / 2)];
   // self.cover_img.backgroundColor = [UIColor blueColor];
    [self.contentView addSubview:self.cover_img];
    
    self.text = [[UILabel alloc] initWithFrame:CGRectMake(10, self.contentView.frame.size.height / 7 + self.contentView.frame.size.height / 2 , self.contentView.frame.size.width / 5 * 4, self.contentView.frame.size.height / 4 - 20)];
    self.text.numberOfLines = 0;
    self.text.font = [UIFont systemFontOfSize:14];
   // self.text.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.text];
    
    self.price = [[UILabel alloc] initWithFrame:CGRectMake(10, self.contentView.frame.size.height / 4 * 3 + 15, self.contentView.frame.size.width / 2 + 15, self.contentView.frame.size.height / 5 )];
    //self.price.backgroundColor = [UIColor greenColor];
    self.price.textColor = [UIColor colorWithRed:1.0 green:94 / 255.0 blue:35 / 255.0 alpha:1];
     [self.contentView addSubview:self.price];
    
    self.market_price = [[UILabel alloc] initWithFrame:CGRectMake(self.contentView.frame.size.width / 2 + 25, self.contentView.frame.size.height / 4 * 3 + 15, self.contentView.frame.size.width / 2 - 20,  self.contentView.frame.size.height / 5)];
   // self.market_price.backgroundColor = [UIColor orangeColor];
    self.market_price.font = [UIFont systemFontOfSize:13];
    self.market_price.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.market_price];
    
    
    
    

    
}



- (void)setModel:(FormulateListBateModel *)model
{
    
    _model = model;
   // NSLog(@"**********************%@",_model.price);
   // NSLog(@"**********************%@",_model.market_price);
    [self.cover_img sd_setImageWithURL:[NSURL URLWithString:_model.cover_img]];
    self.text.text = _model.text;
    self.price.text = [NSString stringWithFormat:@"￥%@",_model.price];
    self.market_price.text = [_model.market_price.class isSubclassOfClass:[NSNumber class]] ? [_model.market_price stringValue] : _model.market_price;
    
    
    
    
}

@end
